﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace OrganizerLibrary.Extensions
{
    public static class FileInfoExtensions
    {
        public static String GetFileExtension(this FileSystemInfo fileInfo)
        {
            return fileInfo.Extension.TrimStart('.');
        }

        public static Boolean IsLocked(this FileSystemInfo fileInfo)
        {
            try
            {
                using (File.OpenWrite(fileInfo.FullName))
                { }
                return false;
            }
            catch (Exception)
            {
                return true;
            }
        }
    }
}
